package cn.com.czpb.client.custorm;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.com.czpb.client.R;
import cn.com.czpb.client.utils.LogUtils;

/**
 * Created by 猪猪侠 on 2018/3/22.
 */

public class NewsReadDialog extends Dialog {

    @BindView(R.id.tv_title_id)
    TextView tvTitleId;
    @BindView(R.id.tv_double_id)
    TextView tvDoubleId;
    @BindView(R.id.tv_time_id)
    TextView tvTimeId;
    private Activity activity;

    public NewsReadDialog(@NonNull Context context) {
        super(context);
    }

    public NewsReadDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        activity = (Activity) context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
    }
    private void init() {
        WindowManager windowManager = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE);
        int width = windowManager.getDefaultDisplay().getWidth();
        LogUtils.i("with-->" + width);
        View view = LayoutInflater.from(activity).inflate(R.layout.dialog_read, null);
        ButterKnife.bind(this,view);
        setContentView(view);
        Window dialogWindow = getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        dialogWindow.setGravity(Gravity.END | Gravity.BOTTOM);
        lp.width = width;
        dialogWindow.setAttributes(lp);
        tvTitleId.setText("标题标题,标题标题,标题标题,标题标题,标题标题,标题标题,标题标题,标题标题,标题标题,");
        tvDoubleId.setText("1X");
        tvTimeId.setText("5'");
    }

    @OnClick({R.id.img_close_id, R.id.tv_double_id, R.id.tv_time_id, R.id.img_previous_id, R.id.img_play_id, R.id.img_next_id})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_close_id:
                LogUtils.i("play");
                break;
            case R.id.tv_double_id:
                LogUtils.i("1X");

                break;
            case R.id.tv_time_id:
                LogUtils.i("5秒倒计时");
                break;
            case R.id.img_previous_id:
                LogUtils.i("上一曲");
                break;
            case R.id.img_play_id:
                LogUtils.i("播放");
                break;
            case R.id.img_next_id:
                LogUtils.i("下一曲");
                break;
        }
    }
}
